<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<button onclick="addObj()">点击创建对象</button>
<script>
    var Anm = function (name) {
        this.name = name;
    }
    var arr = [1, 2, 3, 4]
    var anm = {};
    function addObj() {
        for (var i = 0; i < arr.length; i++) {
            anm[i] = new Anm(i);
            console.log(anm[i].name);
        }
        console.log(anm[0].name); // xiaobai
    }

</script>
</body>
</html>